#ifndef QBCISCREENCONTROLLER_H
#define QBCISCREENCONTROLLER_H

#include <QByteArray>
#include <QObject>
#include <QtDebug>
#include <QThread>
#include <QBciRender>

class QBciScreenController : public QObject {
  Q_OBJECT
public:
  struct BlockConfig {
    int ID = -1;
    double Freq = -1;
    double Duti = -1;
    bool Enable = true;
    bool Flick = true;
    QString Label;
  };

public:
  QBciScreenController(QObject *parent = nullptr);
  ~QBciScreenController();

  QByteArray getConstruction();

public slots:
  void setBlock(const int &ID, const bool &enable, const double &freq,
                const double &duti, const QString &label);
  void setBlock(const int &ID, const bool &enable, const double &freq,
                const double &duti);
  void setBlock(const int &ID, const bool &enable,
                const double &duti, const QString &labe);

  void setBlockEnable(const int &ID, const bool &enable);
  void setBlockFreq(const int &ID, const double &enable);
  void setBlockDuti(const int &ID, const double &duti);
  void setBlockLabel(const int &ID, const QString &label);
  void setBlockFlick(const int &ID, const bool &flick);

  void setBlockEnable(const QString &label, const bool &enable);
  void setBlockFreq(const QString &label, const double &freq);
  void setBlockDuti(const QString &label, const double &duti);
  void setBlockFlick(const QString &label, const bool &flick);

  void setWaveType(const QBciRender::WaveType &type);

  void setAllBlock();
  void resetAllBlock();

signals:
  void newConstruction(const QByteArray& mesg);

public:
  QThread *screenControllerThread;

public:
  void ScreenControllerInit();

private:
  QBciRender::WaveType Wave = QBciRender::square;

  // block Num
  int BlockNum = 13;
  // save config
  QList<BlockConfig> ConfigList;
};

#endif // QBCISCREENCONTROLLER_H
